#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/log"
require "#{LKP_SRC}/lib/string_ext"

while (line = $stdin.gets)
  line = line.resolve_invalid_bytes

  case line.chomp!
  when /^Total Average\s+:.*= ([0-9.]+) ([a-z]+)$/
    unit = $2
    average = $1
  end
end

puts "total_average_#{unit}: #{average}"
